package net.dgg.zz.kafka;

import net.dgg.framework.tac.kafka.annotation.DggKafkaListener;
import net.dgg.zz.production.excption.ProductOrderExcption;
import net.dgg.zz.production.nodeOverdue.service.ProductOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 同步客户名称
 * @author 郁川东
 * @date 2020/9/2 10:52
 */
@Component
public class UpdateCustomerNameKafkaCustomer {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ProductOrderService productOrderService;
    /**
     * @Description 售后单状态变更kafka：
     * @author 郁川东
     * @date 2020/9/2
     * @param param
     * @return void
     */
    @DggKafkaListener(topicName="KAFKA_ORDER_CUSTOMER_NAME_CHANGE", groupId="KAFKA_ORDER_CUSTOMER_NAME_CHANGE_UPDATE_ZZSC",threadNum=5,whichDataSource = 0)
    public void updateCustomerName(Map param) {
        try {
            logger.error("同步客户信息参数：",param.toString());
            productOrderService.updateCustomerName(param);
            logger.error("同步客户名称kafka成功", param.get("customerId").toString());
        } catch (ProductOrderExcption e){
            logger.error("同步客户名称kafka失败,原因:{}", e.toString());
        } catch (Exception e) {
            logger.error("客户名称kafka失败,原因:{}", e.toString());
        }
    }
}
